import 'package:flutter/material.dart';
import 'package:wheel_of_fortune/http/wheel_server.dart';
import 'package:wheel_of_fortune/model/candy_record_model.dart';

class CandyProvider extends ChangeNotifier {
  List<CandyRecordModel> recordList = [];
  double candyBalance = 0;
  initData() {
    getCandyRecord();
    getCandyBalance();
  }

  getCandyRecord() async {
    try {
      recordList = await WheelService().getCandyRecord();
    } catch (e) {
      recordList = [];
      print('error ----------- $e');
    }
    notifyListeners();
  }

  Future getCandyBalance() async {
    try {
      final data = await WheelService().getCandyBalance();
      candyBalance = data['balance'];
    } catch (e) {
      candyBalance = 0;
    }
    notifyListeners();
  }
}
